﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace Subtle.Test
{
	public static class ValidationHelper
	{
		/// <summary>
		/// Validate Model
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		public static IList<ValidationResult> ValidateModel(object model)
		{
			var validationResults = new List<ValidationResult>();
			var ctx = new System.ComponentModel.DataAnnotations.ValidationContext(model, null, null);
			Validator.TryValidateObject(model, ctx, validationResults, true);
			return validationResults;
		}
	}
}
